package main.java.indi.zyj.c150.dps;


import java.util.Scanner;

/**

         .....
         .#...
         .#.##
         ....#
         ....#

 */
public class _04_CutCake {

    static int m, n, ans = 0, temp = 0;

    static Character[][] map = new Character[110][110];
    static boolean[][] visited = new boolean[110][110];
    static int[][] dir = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}};

    static void Dfs(int x, int y){

        if (x<0 || x>=m || y<0 || y>=n || visited[x][y] || map[x][y] == '.'){
            return;
        }

        visited[x][y] = true;
        temp++;

        for (int i = 0; i < 4; i++) {
            int nextX = x + dir[i][0], nextY = y + dir[i][1];
            Dfs(nextX, nextY);
        }

//        visited[x][y] = false;

    }


    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);

        System.out.println("请输入迷宫的行列数:");
        m = scan.nextInt();
        n = scan.nextInt();

        for (int i = 0; i < m; i++) {
            String s = scan.next();
            for (int j = 0; j < n; j++) {
                map[i][j] = s.charAt(j);
            }
        }

        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (map[i][j] == '#' && !visited[i][j]){
                    Dfs(i ,j);
                    if (temp > ans){
                        ans = temp;
                        temp = 0;
                    }
                }
            }
        }

        System.out.println(ans);


    }

}
